const debounce = (func, time, isDebounce, ctx) => {
    var timer, lastCall, rtn;
    //防抖函数
    if (isDebounce) {
        rtn = (...params) => {
            if (timer) clearTimeout(timer);
            timer = setTimeout(() => {
                func.apply(ctx, params);
            }, time);
        };
    } else {//节流函数
        rtn = (...params) => {
            const now = new Date().getTime();
            if (now - lastCall < time && lastCall) return;
            lastCall = now;
            func.apply(ctx, params);
        };
    }
    return rtn;
};

export default debounce

export const getAssetsFile = (url) => {
    return new URL(`../assets/${url}`, import.meta.url).href
}
